package com.fusuhai.controller;

import com.fusuhai.bean.InsectBean;
import com.fusuhai.service.InsectService;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


@RestController
@RequestMapping("insects")
public class InsectConfig {
    @Resource
    private InsectService insectService;

    @RequestMapping("addUser")
    public void addUser(InsectBean insect) {
        insectService.addInsect(insect);
    }

    @RequestMapping("selectInsect")
    public InsectBean selectInsect(int id) {
        return insectService.selectInsect(id);
    }

    @RequestMapping("selectInsectByName")
    public PageInfo<InsectBean> selectInsectByName(@RequestParam(value = "pageNO", defaultValue = "1") int pageNO,
                                                   @RequestParam(value = "pageSize", defaultValue = "5") int pageSize,
                                                   String name, String host) {
        return insectService.selectInsectByName(pageNO, pageSize, name, host);
    }


    @RequestMapping("selectAllInsect")
    public PageInfo<InsectBean> selectAllInsect(@RequestParam(value = "pageNO", defaultValue = "1") int pageNO,
                                                   @RequestParam(value = "pageSize", defaultValue = "5") int pageSize
                                                   ) {
        return insectService.selectAllInsect(pageNO, pageSize);
    }
}
